package com.myblog.controller;

import com.github.pagehelper.PageInfo;
import com.myblog.pojo.Article;
import com.myblog.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Controller
public class ArticleController {

    @Autowired
    ArticleService articleService;

    @RequestMapping("/index")
    public String index(Model model, Integer pageNum){

        PageInfo<Article> result = articleService.query(pageNum==null ? 1 : pageNum, 2);

        model.addAttribute("result", result);

        return  "client/index";
    }

}
